/**
 * 商品管理详情混入信息
 * */
import { ApiRequest } from '@api/basePage';

export default {
    data () {
        return {
            viewData: {}, // 详情信息
            auditCompsData: [], // 审核组件信息
            specsColumns: [], // 规格属性
            auditForm: {}, // 审核表单信息
            aloading: false,
            cloading: false,
            viewContent: '',
            uuid: ''
        }
    },
    created () {
        this.uuid = this.$route.query.uuid;
        this.getConfigData();
    },
    methods: {
        //  获取基础信息
        getViewPageInfo () {
            let data = {
                uuid: this.uuid
            }
            // 开始请求信息
            ApiRequest(this.requestApi.getViewPageInfo.url, this.requestApi.getViewPageInfo.type, data).then(res => {
                this.viewData = res.retData;
            })
        },
        // 审核通过
        handleAgree (name) {
            if (this.aloading) {
                return;
            }
            if (this.auditForm.chooseReason === '' && this.auditForm.inputReason === '') {
                this.$Message.error('请选择原因!');
                return false;
            }
            this.aloading = true;
            let data = {
                auditType: '0', // 审核通过
                uuid: this.uuid,
                chooseReason: this.auditForm.chooseReason,
                inputReason: this.auditForm.inputReason
            }
            // 开始请求商品列表
            ApiRequest(this.requestApi.toAudit.url, this.requestApi.toAudit.type, data).then(res => {
                this.aloading = false;
                this.$Message.success('审核成功');
            })
        },
        // 拒绝审核
        handleRefuse (name) {
            if (this.cloading) {
                return;
            }
            if (this.auditForm.inputReason === '') {
                this.$Message.error('请输入拒绝原因!');
                return false;
            }
            this.cloading = true;
            let data = {
                productUuid: this.uuid,
                auditReason: this.auditForm.chooseReason + ',' + this.auditForm.inputReason
            }
            // 开始请求商品列表
            ApiRequest(this.requestApi.refuse.url, this.requestApi.refuse.type, data).then(res => {
                this.auditModal = false;
                if (res.retStatus === '1') {
                    this.cloading = false;
                    this.$Message.success('拒绝成功');
                    setTimeout(() => {
                        this.$router.go(-1);
                    }, 1500)
                }
            })
        },
        // 组件内数据改变
        handleChangeFormData (data) {
            this.$set(this.auditForm, 'data', data);
        }
    }
}
